<%@page import="utils.SCmd"%>
<%@page import="utils.SeU"%>
<%@page import="javax.naming.Context"%>
<%@page import="swimv2.session.*"%>
<%@page import="swimv2.entity.*"%>
<%@page import="java.util.*"%>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
<link href="css/layout_2_col.css" rel="stylesheet" type="text/css">
</head>
<body>
	<%
		//Recupero dei parametri e settaggio dei flag
		boolean logged = false;
		if(session.getAttribute(SeU.STATUS_ATTRIBUTE)=="user")
		{
			logged = true;
		}
	%>
	<div id="main-wrapper-o">
		<div id="main-wrapper-i">
			<div id="header-o">
				<div id="header-i">
				
					<div id="logo_block">
						<a href="<%= response.encodeURL("Home") %>">
							<h2>Swim</h2>
						</a>
					</div>
					<div id="search_box">
						<form>
							<input type="text" name="<%= SeU.USERNAME_ATTRIBUTE %>" />
							<input type="submit" value="search">
						</form>
					</div>
				</div>
			</div>
			<!-- END HEADER-->
			
			<div id="side_left_o">
				<div id="side_left_i">
				<h2>Top 100 User</h2>
				<%if(logged){ %>
					
					<!-- AREA TOP 100 USER -->
					<div></div>		
					
				<%} %>
				</div>
			</div>
			<div id="main-content-0">
				<div id="main-content-i">
					<%if(logged){ %>
						<!-- INSERIMENTO NUOVA RICHIESTA PUBBLICA -->
						<div>
							<form action='<%= response.encodeRedirectURL("Message") %>'>
								Object: <input type="text" name="<%= SeU.SUBJECT_ATTRIBUTE %>"><br>
								Text: <input type="text" name="<%= SeU.TEXT_ATTRIBUTE %>"><br>
								<input type="hidden" name="<%=SCmd.SERVLET_COMMAND %>" value="<%=SCmd.CREATE_PUBLIC_REQUEST %>">
								<input type="submit" value="Invia">
							</form>
						</div>
						
						<!-- INSERIMENTO RICHIESTE PUBBLICHE -->
						<%
							List<Request>rs = (List<Request>)session.getAttribute(SeU.REQUEST_ATTRIBUTE_ID);
							for(Request r : rs)
							{
						%>
								<div>
									<span><%=r.getObject() %></span>
									<span><a href="Message?<%=SeU.REQUEST_ATTRIBUTE_ID +"="+ r.getId() %>">Rispondi</a></span>
								</div>
								<% 
							}
						%>
						
					<%} %>	
				</div>
			</div><div id="side_right_o">
				<div id="side_right_i">
					<%if(logged) 
					{
						User u = (User)session.getAttribute(SeU.USER_ATTRIBUTE);
					
					%>
						<div id="Box_Utente">
							<a href="<%=response.encodeURL("Profile")%>">
								<span><%=u.getName()%></span>
								<span><%=u.getSurname()%></span>
							</a>
						</div>
						<ul>
							<li><a href="<%=response.encodeURL("Message") %>">Messaggi</a></li>
							<li><a href="<%=response.encodeURL("Profile?action=amici") %>">Amici</a></li>
						</ul>
						
					<%}else { %>
						<h1>Login</h1>
						<form action="<%= response.encodeURL("login") %>" method="post">
							<input type="hidden" />
							Username: <input type="text" name="<%= SeU.USERNAME_ATTRIBUTE %>" /><br />
							Password: <input type="text" name="<%= SeU.PASSWORD_ATTRIBUTE %>" /><br />
							<input type="submit" value="Login" />
						</form>
						<a href="<%= response.encodeURL("register.jsp") %>"><span>register</span></a>
					<%} %>
				</div>
			</div>
		<!--      MAIN CONTENT      -->
			
		<!-- END  MAIN CONTENT      -->	
			
			<div id="clear"></div>
			<div id="footer_o">
				<div id="footer_i">
					
					
					
				</div>
			</div>
		</div>
	</div><!--END WRAPPER-->
</body>
</html>